# -*- coding: utf-8 -*-

class Annotation:
    """
        annotation: key, value pair
        start: start of annotation
        end: end of annotation
    """
    def __init__(self, annotation, start = None, end = None):
        self.name = annotation[0]
        self.value = annotation[1]
        self.start = start
        self.end = end
    
    def __unicode__(self):
        return "Annotation. %s: %s, (%d, %d)" % (self.name, self.value, self.start, self.end)
    
    def serialize(self):
        """
        Serializes the annotation.
        Returns:
          A dict containing the name, value, and range values.
        """
        return {'name': self.name,
                'value': self.value,
                'range': {'start': self.start,
                          'end': self.end}}        